import router from '../router/index.js'

const sessionStorage = window.sessionStorage;

export default {
  getItem(key) {
    if (sessionStorage.getItem(key) === null) {
      router.push({ path: '/' });
      this.removeItem('active');
      return null
    } else {
      return sessionStorage.getItem(key);
    }
  },
  setItem(key, val) {
    sessionStorage.setItem(key, val);
  },
  clear() {
    sessionStorage.clear();
  },
  keys(index) {
    return sessionStorage.key(index);
  },
  removeItem(key) {
    sessionStorage.removeItem(key);
  }
}